package com.hsource.paymentcenter.util.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author yangYang
 * @version 1.0
 * @date 2020/9/23 16:43
 * @describe RedisKey获取工具类
 */
@Component
public class RedisKeyUtil {
    @Autowired
    private RedisUtil redisUtil;
    private static RedisKeyUtil redisKeyUtil;

    @PostConstruct
    public void init() {
        redisKeyUtil = this;
        redisKeyUtil.redisUtil = this.redisUtil;
    }
    public static final String  DOCTORLIST="DOCTORLIST";

    public static final String  IMAGE_TEXT_PROBLEM="IMAGE_TEXT_PROBLEM";

    public static final String  QUICK_QUESTIONS="QUICK_QUESTIONS";

    public static final String ORDER_LIST="ORDER_LIST";

    public static final String ORDER_LIST_STRING="ORDER_LIST_STRING";

    public static final String ORDER_LIST_NOTIFY="ORDER_LIST_NOTIFY";

    public static final String ORDER_LIST_UNIFIED="ORDER_LIST_UNIFIED";

    //redis topic 通道管理
    public static final String TOPIC_ORDER_CENTER="orderCenter";

    /**
     * 获取相应功能KEY
     * @param params
     * @param type
     * @return
     */
    public static String  getRedisKeyString(String params,String type){
        if(type.equals(DOCTORLIST)){
            return  redisKeyUtil.redisUtil.keyBuilder("doctor", "list");
        }
        if(type.equals(IMAGE_TEXT_PROBLEM)){
            return redisKeyUtil.redisUtil.keyBuilder("problem",IMAGE_TEXT_PROBLEM,params);
        }
        if(type.equals(QUICK_QUESTIONS)){
            return  redisKeyUtil.redisUtil.keyBuilder("problem", QUICK_QUESTIONS, params);
        }
        if(type.equals(ORDER_LIST)){
            return  redisKeyUtil.redisUtil.keyBuilder("order", ORDER_LIST, params);
        }
        if(type.equals(ORDER_LIST_STRING)){
            return redisKeyUtil.redisUtil.keyBuilder("order",ORDER_LIST_STRING,params);
        }
        if(type.equals(ORDER_LIST_NOTIFY)){
            return redisKeyUtil.redisUtil.keyBuilder("order",ORDER_LIST_NOTIFY,params);
        }
        if(type.equals(ORDER_LIST_UNIFIED)){
            return redisKeyUtil.redisUtil.keyBuilderByPaymentCenter("order",ORDER_LIST_UNIFIED,params);
        }
        return "";
    }
}
